<template>
  <div v-loading="loading" class="parentStyle">
    <div style="overflow: auto;height: calc(100% - 50px);">
      <table border="1" cellspacing="0" cellpadding="0">
        <tr>
          <td style="width: 20%;" class="texts">{{ $t('公告标题') }}:</td>
          <td colspan="3">
            <span>{{ investor.title }}</span>
          </td>
        </tr>
        <tr>
          <td class="texts">{{ $t('公告内容') }}:</td>
          <td colspan="3">
            <span style="display: block;max-height: 400px;overflow: auto;" v-html="investor.remark" />
          </td>
        </tr>
        <tr>
          <td class="texts">{{ $t('随函附件') }}:</td>
          <td colspan="3">
            <span v-for="(item, index) in form.fileList" :key="index">
              <el-link class="link-a" type="primary" @click="onlinePreview(item)">{{ item.name }}</el-link><br>
            </span>
          </td>
        </tr>
        <tr v-if="investor.status === '发送成功' || investor.status === '发送失败'">
          <td class="texts">{{ $t('发送状态') }}:</td>
          <td colspan="3">
            <span :style="{color: investor.status === '发送失败' ? 'red' : '#48bd4a'}">{{ $t(investor.status) }}</span>
          </td>
        </tr>
        <tr v-if="investor.status === '发送成功' || investor.status === '发送失败'">
          <td style="width: 20%;" class="texts">
            {{ $t('发送人') }}
          </td>
          <td style="width: 30%;">
            {{ $t(investor.nickName) }}
          </td>
          <td style="width: 20%;" class="texts">
            {{ $t('发送时间') }}
          </td>
          <td style="width: 30%;">
            {{ $t(form.updateTime) }}
          </td>
        </tr>
      </table>
    </div>
    <div slot="footer" class="dialog-footer" style="text-align: center;">
      <el-button @click="cancel">{{ $t("取消") }}</el-button>
    </div>
    <!-- 预览 -->
    <OnlinePreview ref="OnlinePreview" />
  </div>
</template>

<script>
// import EditorTxt from '@/components/Editor'
import { getLpPublicBulletin } from '@/api/fund/lpBase/lp/affiche/affiche.js'
// import { listLpAnnouncementTemplate } from '@/api/fund/lpBase/lp/affiche/afficheListTemplate'
export default {
  components: {
    // EditorTxt
  },
  data() {
    return {
      // 表单参数
      form: {},
      // 遮罩层
      loading: false,
      // 关键字
      keywordList: [],
      // lpTemplate: [],
      title: '',
      investor: {
        title: '',
        remark: '',
        status: '',
        nickName: ''
      }
    }
  },
  created() {
    // 获取公告类型
    // listLpAnnouncementTemplate().then(response => {
    //   this.lpTemplate = response.rows
    // })
    this.getDicts('lp_poster_keywords').then(response => {
      this.keywordList = response.data
    })
  },
  methods: {
    // 初始化数据 listOfFundersInTheFund
    init(data) {
      if (data !== null && data.id !== undefined) {
        this.loading = true
        getLpPublicBulletin(data.id).then(response => {
          this.form = response.data
          this.form.lpBaseList.forEach(item => {
            if (item.lpId === data.lpId) {
              this.investor.title = item.title
              this.investor.remark = item.remark
              this.investor.status = item.status
              this.investor.nickName = item.nickName
              if (item.fileList !== undefined && item.fileList !== null) {
                item.fileList.forEach(temp => {
                  this.form.fileList.push({ name: temp.name, id: temp.id })
                })
              }
            }
          })
          this.loading = false
        })
      } else {
        this.reset()
      }
    },
    // 取消按钮
    cancel() {
      this.$parent.$parent.emailReviewViewOpen = false
    },
    // 预览附件
    onlinePreview(row) {
      var id = row.id
      if (id === undefined || id === null) {
        id = row.fileId
      }
      this.$refs.OnlinePreview.onlinePreviewFile(id)
    }
  }
}

</script>
<style scoped>
table{
  border-collapse: collapse;
  border: 1px solid #DFE6EC;
}
td {
  font-size: 14px;
  line-height: 25px;
  text-align: left;
  padding: 10px;
}
.texts{
  background: #F6F7FB;
}
</style>
